package com.hcg.multidatasourceofanno3.controller;

import com.hcg.multidatasourceofanno3.domain.User;
import com.hcg.multidatasourceofanno3.service.CmUserService;
import com.hcg.multidatasourceofanno3.service.HcUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class UserController {

    @Autowired
    private CmUserService cmUserService;
    @Autowired
    private HcUserService hcUserService;

    @PostMapping("/user/cmsave")
    public void cmSaveUser(@RequestBody User user){
        log.info(" ************* invoke save function start ************* ");
        cmUserService.saveUser(user);
        log.info(" ************* invoke save function end ************* ");
    }

    @PostMapping("/user/hcgsave")
    public void hcgSaveUser(@RequestBody User user){
        log.info(" ************* invoke save function start ************* ");
        hcUserService.saveUser(user);
        log.info(" ************* invoke save function end ************* ");
    }

}
